<template>
	<view class="box">
		<text class="title">我的车型</text>
		<view class="car-info">
			<image :src="maintainConfirm.carInfo.carLogoPic" mode=""></image>
			<view class="info">
				<text class="name">{{maintainConfirm.carInfo.carBrand}}</text>
				<text class="parameter">{{maintainConfirm.carInfo.carSeries}} {{maintainConfirm.carInfo.carType}}</text>
			</view>
		</view>
		<text class="title">套餐内容</text>
		<view class="content">
			<!-- <image src="" mode=""></image> -->
			<view class="">
				<text class="name">{{maintainConfirm.service}}</text>
				<!-- <text class="tag">壳牌蓝标（4L）+更换机滤+工时费</text> -->
			</view>
		</view>
	</view>
	<view class="order">
		<text class="label">订单价格</text>
		<text class="value">¥{{price}}</text>
	</view>
	<button class="btn" @click="submit">提交订单</button>
</template> 

<script setup>
	import {
		onLoad,
		onReachBottom,
		onShow,
	} from '@dcloudio/uni-app'
	import {
		wxOpenid
	} from '@/utils/login-sdk.js'
	import {
		orderPreMaintain
	} from '@/api'
	import { ref } from 'vue';
	const maintainConfirm = ref()
	const price = ref(0)
	onLoad(()=>{
		maintainConfirm.value = JSON.parse(uni.getStorageSync('maintainConfirm'))
		price.value = maintainConfirm.value.serviceData.salePrice*maintainConfirm.value.num / 100
		
	})
	/** 提交订单 */
	const submit = async()=>{
		const {memberId} = await wxOpenid()
		const res = await orderPreMaintain({
			memberId:memberId,
			productInfoId:maintainConfirm.value.productInfoId,
			carInfoId:maintainConfirm.value.carInfoId,
			num:maintainConfirm.value.num
		})
		const service = maintainConfirm.value.serviceData
		uni.navigateTo({
			url:"/pages/pay/pay?preOrderId="+res.result.preOrderId+'&token='+res.result.token+'&orderAmount='+service.salePrice+'&payAmount='+service.salePrice+'&num='+maintainConfirm.value.num+'&businessType=3'
		})
	}
</script>

<style lang="scss">
	page {
		background: #F8F5F0;
	}
	.box{
		width: 702rpx;
		padding-bottom: 52rpx;
		background: #FFFFFF;
		border-radius: 36rpx;
		margin: 21rpx 24rpx 17rpx;
		overflow: hidden;
		
		.title{
			font-size: 30rpx;
			color: #16191B;
			display: block;
			margin: 49rpx 0 44rpx 54rpx;
		}
		.car-info{
			display: flex;
			margin: 0 55rpx 0 55rpx;
			border-bottom: 2rpx solid rgba(242, 242, 242, 1);
			padding-bottom: 40rpx;
			image{
				width: 65rpx;
				height: 65rpx;
				
				display: block;
				margin-right: 20rpx;
			}
			.info{
				.name{
					color: rgba(22, 25, 27, 1);
					font-size: 28rpx;
					display: block;
					
				}
				.parameter{
					color: rgba(165, 165, 165, 1);
					font-size: 24rpx;
				}
			}
		}
		.content{
			display: flex;
			margin: 0 55rpx 0 55rpx;
			image{
				width: 126rpx;
				height: 126rpx;
				background: pink;
				display: block;
				margin-right: 20rpx;
			}
			view{
				.name{
					color: rgba(22, 25, 27, 1);
					font-size: 30rpx;
					color: #16191B;
					margin-bottom: 16rpx;
					display: block;
				}
				.tag{
					padding: 12rpx 17rpx;
					
					background: #FFEBD3;
					border-radius: 10rpx;
					font-size: 20rpx;
					color: #FE9B23;
					
					
				}
			}
		}
	}
	.order{
		width: 702rpx;
		height: 106rpx;
		background: #FFFFFF;
		border-radius: 36rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 0 auto;
		.label{
			font-size: 30rpx;
			color: #16191B;
			margin-left: 54rpx;
		}
		.value{
			font-weight: bold;
			font-size: 30rpx;
			color: #FF4817;
			margin-right: 43rpx;
		}
	}
	.btn{
		position: absolute;
		bottom: 107rpx;
		left: 55rpx;
		width: 640rpx;
		height: 100rpx;
		background: linear-gradient(90deg, #FFC53D 0%, #FE9B23 51%, #FFC53D 100%);
		box-shadow: 4rpx 12rpx 18rpx 0rpx rgba(254,155,35,0.25);
		border-radius: 28rpx;
		color: #fff;
		font-weight: bold;
		font-size: 36rpx;
		line-height: 100rpx;
	}
</style>
